import sha1 from 'sha1'
import JSEncrypt from 'jsencrypt'
//加密
// export const clos_encryptDes2 = (data,time) => {
//     return sha1('1'+"_"+'f96de898642941ee8401bce20a076f18' + "_" + 'APId1482c4fc9' + "_" + time + "_" + data)
// }
export const clos_encryptDes = (data,time,type) => {
    if(type==1){
        return sha1('f96de898642941ee8401bce20a076f18' + "_" + 'APId1482c4fc9' + "_" + time + "_" + data)
    }else{
        return sha1('1'+"_"+'f96de898642941ee8401bce20a076f18' + "_" + 'APId1482c4fc9' + "_" + time + "_" + data)
    }

}
//时间毫秒
export const time = () => {
    let date = new Date()
    let time = date.valueOf()
    return time
}

// 使用公钥 加密
export const jseEncryption = (key,data) => {
    let encrypt = new JSEncrypt()
    // 设置公钥
    encrypt.setPublicKey(key)
    return encrypt.encrypt(data)
}

//使用私钥 解密
export const jseDecrypt = (key,data) => {
    let decrypt = new JSEncrypt()
    // 设置私钥
    decrypt.setPrivateKey(key)
    return decrypt.decrypt(data)
}
